<template>
	<uv-tabbar :value="value" @change="tabChange">
		<uv-tabbar-item :text="item.text" :icon="item.icon" v-for="(item,idx) in tabbarList"
			:key="idx"></uv-tabbar-item>
	</uv-tabbar>
</template>

<script>
	export default {
		name: "MyTabbar",
		data() {
			return {
				tabbarList: [
					{
						text: "首页",
						icon: "home",
						routePath: "/pages/index/index",
					},
					{
						text: "商城",
						icon: "shopping-cart",
						routePath: "/pages/shop/index",
					},
					{
						text: "我的",
						icon: "account",
						routePath: "/pages/mine/index",
					},
				]
			}
		},
		computed:{
			value(){
				return getApp().globalData.tabbarValue
			}
		},
		mounted() {
			
		},
		methods: {
			tabChange(index) {
				if (getApp().globalData.tabbarValue === index) return
				getApp().globalData.tabbarValue = index
				uni.switchTab({
					url: this.tabbarList[index].routePath
				})
			}
		},

	}
</script>

<style lang="scss" scoped>

</style>